home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / human interface toolbox / ictbsample / main.c < prev   
Encoding:
C/C++ Source or Header  |  2000-06-23  |  2.8 KB  |  123 lines

  1. /*
  2.     File:        main.c
  3.  
  4.     Contains:    This snippet shows the an example of ictb resource this is discussed in 
  5.                 Inside Macintosh:Macintosh Toolbox Essentials, page 6-158 t0 6-164.
  6.                 It is based on the Dialog Manager Q&A technote.  You can find the technote
  7.                 in the Dev.CD Jun 96 RL
  8.                       Technical Documentation
  9.                             Macintosh Technical Notes
  10.                               Archive
  11.                                 Toolbox
  12.                                       tb_525.html.
  13.              
  14.                 There is no Rez template for it, and no ResEdit template or editor.  
  15.                 This sample ictbSample.r shows how you can do one by hand.
  16.  
  17.                 The best solution is to get Resorcerer which provides an excellent ictb editor. 
  18.                 With Resorcerer, it is really simple to use ictb in your dialog boxes.
  19.  
  20.     Written by: Albert Hui    
  21.  
  22.     Copyright:    Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
  23.  
  24.                 You may incorporate this Apple sample source code into your program(s) without
  25.                 restriction. This Apple sample source code has been provided "AS IS" and the
  26.                 responsibility for its operation is yours. You are not permitted to redistribute
  27.                 this Apple sample source code as "Apple sample source code" after having made
  28.                 changes. If you're going to re-distribute the source, we require that you make
  29.                 it clear in the source that the code was descended from Apple sample source
  30.                 code, but that you've made changes.
  31.  
  32.     Change History (most recent first):
  33.                 8/6/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  34.                 
  35.  
  36. */
  37.  
  38. #include <TextEdit.h>
  39. #include <Fonts.h>
  40. #include <Windows.h>
  41. #include <Dialogs.h>
  42. #include <Menus.h>
  43.  
  44.  
  45. // constants
  46.  
  47. #define    kMyDialog        128
  48. #define kDone            1
  49. #define    kCheckOneItem    2
  50. #define    kCheckTwoItem    3
  51. #define kCheckThreeItem 4
  52. #define    kEditTextItem1    5
  53. #define    kEditTextItem2    6
  54. #define    kEditTextItem3    7
  55.  
  56. // prototypes
  57.  
  58. void main(void);
  59. void InitStuff(void);
  60. void DoDialog(void);
  61. void SetupDialog(DialogPtr theDialog);
  62. void PrepareFreeDialog(DialogPtr theDialog);
  63.  
  64.  
  65.  
  66.  
  67. /* main entry point */
  68.  
  69. void main(void)
  70. {
  71.     InitStuff();
  72.     DoDialog();
  73.     ExitToShell();
  74. }
  75.  
  76.  
  77. /* initialize the Mac managers */
  78.  
  79. void InitStuff(void)
  80. {
  81.     InitGraf(&qd.thePort);
  82.     InitFonts();
  83.     InitWindows();
  84.     InitMenus();
  85.     TEInit();
  86.     InitDialogs(nil);
  87.     InitCursor();
  88.     FlushEvents(everyEvent,0);
  89. }
  90.  
  91.  
  92. /*    display dialog, and handle pretty standard ModalDialog loop.  
  93. */
  94.  
  95. void DoDialog(void)
  96. {
  97.     DialogPtr theDialog;
  98.     short item;
  99.     ControlHandle checkBoxControl;
  100.     short iType;
  101.     Rect iRect;
  102.     
  103.     theDialog = GetNewDialog(kMyDialog,nil,(WindowPtr)-1L);
  104.         
  105.     do {
  106.         ModalDialog(NULL,&item);
  107.         switch (item) {
  108.             case kCheckOneItem:    // check boxes
  109.             case kCheckTwoItem:
  110.             case kCheckThreeItem:
  111.                 GetDialogItem(theDialog,item,&iType,(Handle *)&checkBoxControl,&iRect);
  112.                 SetControlValue(checkBoxControl,!GetControlValue(checkBoxControl));
  113.                 break;
  114.         }    
  115.     } while (item!=kDone);
  116.     
  117.     DisposeDialog(theDialog);
  118. }
  119.  
  120.  
  121.  
  122.  
  123.